home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_2 / new.ife < prev    next >
Text File  |  1995-03-23  |  5KB  |  123 lines

  1. Article 4796 of comp.sys.handhelds:
  2. Path: en.ecn.purdue.edu!noose.ecn.purdue.edu!samsung!spool.mu.edu!sdd.hp.com!hp-pcd!hpcvra.cv.hp.com!billw
  3. From: billw@hpcvra.cv.hp.com. (William C Wickes)
  4. Newsgroups: comp.sys.handhelds
  5. Subject: HP48 New IFERR II
  6. Message-ID: <25590116@hpcvra.cv.hp.com.>
  7. Date: 6 Mar 91 01:07:55 GMT
  8. Organization: Hewlett-Packard Co., Corvallis, OR, USA
  9. Lines: 110
  10.  
  11.  
  12.                       The Return of New IFERR
  13.  
  14. * The library listed at the end of this note is a new version of the
  15. * IFERR library previously posted, which corrects the problem associated
  16. * with command line execution.  You should delete version A of this library
  17. * if you still have it.  Please notify me if any problems arise with
  18. * version B.
  19.  
  20. Several HP 48 programmers have expressed a concern that the current error
  21. trapping mechanism via IFERR is vulnerable to repeated ATTN key
  22. presses, which can prevent a program from cleaning up when it is
  23. interrupted by the user.  This problem arises because IFERR and all
  24. other branching constructs built into the HP 48 check to see if ATTN
  25. key has been pressed so that users cannot (easily) lock themselves
  26. into an uninterruptible loop.
  27.  
  28. The object listed below in ASC-> form is an HP 48 library titled "IF
  29. ERROR ver. B", that provides an alternate version of IFERR/THEN which can be
  30. uniformly substituted for the built-in versions. The difference
  31. between this version and that built into the HP 48 is in the handling
  32. of ATTN.  The ATTN key check is disabled for the THEN
  33. clause of the version provided in this library, allowing for an
  34. "unbreakable" recursive error recovery.
  35.  
  36. Version B includes an additional modification.  The built-in
  37. IFERR...THEN automatically clears the key buffer, and cancels pending
  38. execution of the object associated with the key that started command
  39. line execution.  In version B, the replacement IFERR does not clear
  40. keys.  A new command FLUSHKEYS is provided, so that the programmer can
  41. control pending key execution.  FLUSHKEYS takes no arguments, and
  42. clears the key buffer and the pending key object.
  43.  
  44. An example of the use of the new IFERR is given in the program below.
  45. In the "main" program, a loop display a counter running from 1 to
  46. 1000.  If you press ATTN while it is running, the error trap starts
  47. another counting loop, this time from 1 to 50, to show you that an
  48. error termination sequence of some length is running.  If you
  49. interrupt it, it just restarts itself.
  50.  
  51. In the first line, a temporary variable, et, is allocated. This
  52. variable will hold the error termination procedure after it is created
  53. in the next part of the program. The error termination procedure is
  54. simply a cleanup procedure protected by an IFERR which branches back
  55. to itself recursively if an error occurs in its execution. It is
  56. created in a list to avoid the inclusion of the opening and closing
  57. program quotes, which themselves have attention key checks. The
  58. remainder of the program is protected by IFERR...THEN et EVAL END.
  59.  
  60. Notes:
  61. * You must access the error termination procedure via a temporary variable
  62. because global variable execution itself contains an attention key check.
  63.  
  64. * If your cleanup procedure has an unavoidable error, the only way to stop
  65. infinite execution is by [ON]-[C].
  66.  
  67. * The library (which has ID 1793) is auto-attaching: to use it, all you need
  68. to do is store it in a port (port 0, say) by putting it on the stack and
  69. executing :0:1793 STO, and then turning the HP 48 off and on.
  70.  
  71. * To convert old programs containing IFERR to the new version, you
  72. need only to EDIT (VISIT), then ENTER when the library is attached.
  73. Downloading a program in ASCII form via kermit will also automatically
  74. use the new IFERR.
  75.  
  76. Bill Wickes
  77. HP Corvallis
  78.  
  79. Sample error trap program:
  80. ----------------- cut here ----------------------------------------------
  81. %%HP: T(3)A(R)F(.);
  82. \<< 0 \-> et
  83.   \<< { IFERR 1 50
  84.              FOR j
  85.               "YOUR CLEANUP PROC." 1 DISP 
  86.               "#" j \->STR + " HERE" + 2 DISP
  87.              NEXT 
  88.         THEN et EVAL
  89.         ELSE DONE
  90.         END } OBJ\-> DROP
  91.     'et' STO 
  92.     IFERR 1 1000
  93.       FOR j
  94.         "YOUR MAIN PROC." 1 DISP
  95.         "#" j \->STR " NOW" + + 2 DISP
  96.       NEXT
  97.     THEN et EVAL
  98.     END
  99.   \>>
  100. \>>
  101. ----------------- cut here ----------------------------------------------
  102.  
  103.  
  104. IF ERROR Library:
  105. ----------------- cut here ----------------------------------------------
  106. %%HP: T(3)A(R)F(.);
  107. "04B20F530001946402542525F4250202675627E20224011074100000000BA000
  108. 3D000E4A20C900000000000000000064000E4000000000000000000940000000
  109. 00000000000000000000000000000008300040458454E4100509464542525000
  110. 9064C4553584B4549535200620008300012000E4A208200034000FF000011003
  111. 9100DA1007D10051200D9D20119201070090770B21309107000D9D20E1A81BEE
  112. 60E5E40E8F608BE40D9D20EB78309146A4A35CB916D9D20E68353864467C04B2
  113. 130772441DC83CB916D9D206DB8337314DEC83B2130C8F83D48815EF3133D407
  114. BF60B213008836088362B336B213029E20107400E38412107100D9D20E1A81B2
  115. 1300107200D9D20E1A81FACF3ACFF38AA04A2170D9D2079E60E8E60F6A04B213
  116. 079E60777A5B7970CB916D9D204423079E60E8E6079E60777A572D70B213017D
  117. 00B213029E20107300D9D20A025229E20107200DEBB0B2130D9D20A025229E20
  118. 107000E03521DF6029E20107500B2130D9D20A435210CB04345206DB029E2010
  119. 7600E2A32FCCB01DF6029E20107500B2130D9D20A5252223524423063352A025
  120. 229E20107100E03521DF607D042B2130001F1AC9"
  121.  
  122.  
  123.